<%-- 
    Document   : registerStudent
    Created on : 30-okt-2012, 12:11:36
    Author     : Robbert
--%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>${paginaTitel}</title>
        <script src="../gen_validatorv4.js" type="text/javascript"></script>
        <script src="../md5.js" type="text/javascript"></script>
    </head>
    <body>
        <h1>${paginaTitel} </h1>
        <c:if test="${not empty foutMelding}">
            <p>$foutMelding</p>
        </c:if>
        <c:choose>
            <c:when test="${empty id}">
                <form id="nieuweStudent" action="nieuw" method="post">
                </c:when>
                <c:otherwise>
                    <form id="wijzigStudent" action="wijzig" method="post">
                    </c:otherwise>
                </c:choose>
                <p>
                    <c:if test="${not empty id}">
                        <input type="hidden" name="id" id="id" value="${id}"></input>
                    </c:if>
                </p>
                <table border="0">
                    <tr>
                        <td>Country of Residence:</td>
                        <td><select name="Residence"/>
                    <option value="" selected="selected">Select a country</option>
                    <option value="Netherlands">Netherlands</option>
                    <option value="France">France</option>
                    <option value="United Kingdom">United Kingdom</option>
                    <option value="Germany">Germany</option>
                    </select>
                    </td>
                    </tr>
                    <tr>
                        <td><label for="dob">Date of Birth:</label></td>
                        <td><input type="text" id="dob" name="dob" placeholder="DD/MM/YYYY" value="${dob}" /></td>
                    </tr>
                    <tr>
                        <td>Title:</td>
                        <td><select name="title"/>
                    <option value="Mr" selected="selected">Mr</option>
                    <option value="Ms">Ms</option>
                    <option value="Mrs">Mrs</option>
                    <option value="Miss">Miss</option>
                    </select>
                    <td>
                        </tr>
                    <tr>
                        <td><label for="fName">First Name:</label></td>
                        <td><input type="text" id="fName" name="fName" placeholder="First Name" value="${fName}" /></td>
                        <td><label for="lName">Last Name:</label></td>
                        <td><input type="text" id="lName" name="lName" placeholder="Last Name" value="${lName}" /></td>
                    </tr>
                    <tr>
                        <td><label for="eMail">E-Mail Address:</label></td>
                        <td><input type="text" id="eMail" name="eMail" placeholder="Enter E-Mail Address" value="${eMail}" /></td>
                        <td><label for="rMail">Re-entered E-Mail Address:</label></td>
                        <td><input type="text" id="rMail" name="rMail" placeholder="Re-enter E-Mail Address" value="${rMail}" /></td>
                    </tr>
                    <tr>
                        <td><label for="passw">Password:</label></td>
                        <td><input type="password" id="passw" name="passw" max-length="16" placeholder="Enter Password" value="${passw}" /></td>
                        <td><label for="rPassw">Re-entered Password:</label></td>
                        <td><input type="password" id="rPassw" name="rPassw" max-length="16" placeholder="Re-enter Password" value="${rPassw}" /></td>
                    </tr>
                    <tr>
                        <td><label for="street">Street:</label></td>
                        <td><input type="text" id="street" name="street" placeholder="Enter Street Name" value="${street}" /></td>
                        <td><label for="homeNumber">Home number:</label></td>
                        <td><input type="text" id="homeNumber" name="homeNumber"  placeholder="Enter Home Number" value="${homeNumber}" /></td>
                    </tr>
                    <tr>
                        <td><label for="zipCode">Zipcode:</label></td>
                        <td><input type="text" id="zipCode" name="zipCode"  placeholder="Enter Zipcode" value="${zipCode}" /></td>
                    </tr>
                    <tr>
                        <td><input class="submit" type="submit" value="Create account" /></td>
                    </tr>
                </table>
            </form>
            <script  type="text/javascript">
                
             //   var hashedPassword=function() { 
             //       var password=getElementById("passw");
             //       var hash=calcMD5(password);
             //        return hash;
             //   }
                
                
                var frmvalidator = new Validator("nieuweStudent");
                frmvalidator.addValidation("dob","req");
                frmvalidator.addValidation("fName","req","Please enter your First Name");
                frmvalidator.addValidation("fName","maxlen=20","reg","Max length for FirstName is 20");
                
                frmvalidator.addValidation("lName","req","Please enter your Last Name");
                frmvalidator.addValidation("lName","maxlen=20","reg","Max length for LastName is 20");
 
                frmvalidator.addValidation("eMail","maxlen=50");
                frmvalidator.addValidation("eMail","req");
                frmvalidator.addValidation("eMail","email");
                frmvalidator.addValidation("rMail","eqelmnt=eMail","Your re-entered e-mail is not same as your first e-mail");
                
                frmvalidator.addValidation("rPassw","eqelmnt=passw","The confirmed password is not same as password");
 
                frmvalidator.addValidation("street","maxlen=50");
                frmvalidator.addValidation("homeNumber","req");
                frmvalidator.addValidation("zipCode","req");
                
                frmvalidator.EnableMsgsTogether();
            </script>
    </body>
</html>
